//
//  FQDNewsCategoryFeedCellItemProvider.m
//  FakeQDaily
//
//  Created by mewxiv on 9/18/16.
//  Copyright © 2016 Xensius. All rights reserved.
//

#import "FQDNewsCategoryFeedCellItemProvider.h"
#import "FQDRestModel.h"

#import "YYModel.h"

static NSString *const kNewsCategoryFeed = @"category_feed";

@interface FQDNewsCategoryFeedCellItemProvider ()
@property (nonatomic, strong) NSArray *categoryFeeds;
@end

@implementation FQDNewsCategoryFeedCellItemProvider

- (void)getCellItems:(NSString *)cursorKey completion:(QDailyAPICompleteBlock)completion
{
    [[QDailyAPI sharedAPI] getNewsCategoriesFeed:self.feedId key:cursorKey completion:completion];
}

- (void)parseResponse:(id)response isLatest:(BOOL)isLatest
{
    self.categoryFeeds = [NSArray yy_modelArrayWithClass:[FQDFeed class]
                                               json:response[@"feeds"]];
}

- (void)populateNewCellItemsTo:(NSMutableArray *)originalCellItems
{
    for (FQDFeed *feed in self.categoryFeeds) {
        [originalCellItems addObject:feed];
    }
}

- (NSString *)cacheId
{
    return kNewsCategoryFeed;
}

@end